home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TeX 1995 July
/
TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO
/
tex-k
/
tex-k-archive.past
/
1994.12.gz
/
1994.12
/
000038_Dinh-Tuan.Pham@imag.fr_Wed Dec 7 20:09:51 1994.msg
< prev
next >
Wrap
Internet Message Format
|
1994-12-30
|
9KB
Received: from imag.imag.fr by cs.umb.edu with SMTP id AA13129
(5.65c/IDA-1.4.4 for <tex-k@cs.umb.edu>); Wed, 7 Dec 1994 13:08:16 -0500
Received: from puma.imag.fr by imag.imag.fr with SMTP id AA05109
(5.65c8/IDA-1.4.4 for <tex-k@cs.umb.edu>); Wed, 7 Dec 1994 19:08:14 +0100
Received: by puma.imag.fr (5.0/SMI-SVR4)
id AA16013; Wed, 7 Dec 1994 19:09:51 --100
Date: Wed, 7 Dec 1994 19:09:51 --100
Message-Id: <9412071809.AA16013@puma.imag.fr>
To: tex-k@cs.umb.edu
Subject: xdvik and Selfile
From: Dinh-Tuan.Pham@imag.fr
Content-Length: 7694
Hi,
I have made some modifications to the SelFile widget in xdvik,
which cluld be of interest for inclusion in a future release. The
purpose is implement a file filter so that the widget will display
only *.dvi files (for ex.). The filter mask (*.dvi by default) can be
changed by the user. Also, there is a switch to hide/show the "dot"
files (file with name begining with .).
Here is the patch
--------------------- cut here ---------------------------
*** xdvik/sfSelFile.c.orig Tue Dec 6 16:03:04 1994
--- xdvik/sfSelFile.c Wed Dec 7 08:11:58 1994
***************
*** 89,94 ****
--- 89,100 ----
selFilePrompt,
selFileVScrolls[3];
+ /* addition for file filter */
+ Widget selFileLabel, selFileMask, selFileHide;
+ #define MASKWIDTH 10
+ char fileMask[MASKWIDTH+2] = "*.dvi";
+ /* end addition */
+
Display *SFdisplay;
Pixel SFfore, SFback;
***************
*** 221,226 ****
--- 227,332 ----
{"SelFileDismiss", SFdismissAction},
};
+ /* addition for file filter */
+
+ int maskFile(mask, filename)
+ char *mask, *filename;
+ /* return 1 if file is masked (mask does not match filename), 0 otherwise */
+ {
+ int c, c1;
+
+ while (c = *mask++) {
+ if (c == '*') {
+ while (c1 = *mask++) {
+ if (c1 != '*') {
+ if (!(*filename)) return 1;
+ if (c1 != '?') {
+ while (filename = strchr(filename, c1)) {
+ if (!maskFile(mask, ++filename)) return 0;
+ }
+ return 1;
+ }
+ else filename++;
+ }
+ }
+ return 0;
+ }
+ if (c == '?') { if (!*filename) return 1; }
+ else if (c != *filename) return 1;
+ filename++;
+ }
+ return (*filename)? 1 : 0;
+ }
+
+ #include <sys/stat.h>
+ #if !defined(S_ISDIR) && defined(S_IFDIR)
+ #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+ #endif
+
+ int hideFlag = 1;
+ int showEntry(entryReal, entryShown, statBuf)
+ char *entryReal, **entryShown;
+ struct stat *statBuf;
+ {
+ if (!(S_ISDIR(statBuf->st_mode))) {
+ if (hideFlag)
+ if (entryReal[0] == '.') return 0;
+ if (maskFile(fileMask, entryReal)) return 0;
+ }
+ entryReal[strlen(entryReal)] = SFstatChar(statBuf);
+ return 1;
+ }
+
+ /* ARGSUSED */
+ void maskChanged(w, client_data, event)
+ Widget w;
+ XtPointer client_data;
+ XKeyPressedEvent *event;
+ {
+ char buf[2];
+ register SFDir *dir;
+ register SFEntry *entry;
+ extern void SFupdatePath ();
+
+ if ((XLookupString(event, buf, 2, NULL, NULL) == 1) &&
+ ((*buf) == '\r')) {
+ for (dir = &(SFdirs[SFdirEnd - 1]); dir >= SFdirs; dir--)
+ *(dir->dir) = 0; /* force a re-read */
+ SFupdatePath();
+ }
+ }
+
+ /* ARGSUSED */
+ void hideFiles(w, client_data, event)
+ Widget w;
+ XtPointer client_data;
+ XEvent *event;
+ {
+ register SFDir *dir;
+ register SFEntry *entry;
+ extern void SFupdatePath ();
+
+ hideFlag = 1 - hideFlag;
+ if (hideFlag) {
+ XtVaSetValues(w, XtNlabel, "hidden", NULL);
+ for (dir = &(SFdirs[SFdirEnd - 1]); dir >= SFdirs; dir--) {
+ if (!(dir->nEntries)) continue;
+ dir->vOrigin = 0;
+ for (entry = &(dir->entries[dir->nEntries - 1]);
+ entry >= dir->entries; entry--)
+ entry->statDone = 0;
+ SFdrawLists(SF_DO_SCROLL);
+ }
+ } else {
+ XtVaSetValues(w, XtNlabel, "shown", NULL);
+ for (dir = &(SFdirs[SFdirEnd - 1]); dir >= SFdirs; dir--)
+ *(dir->dir) = 0; /* force a re-read */
+ SFupdatePath();
+ }
+ }
+
+ /* end addition */
+
static void
SFcreateWidgets(toplevel, prompt, ok, cancel)
Widget toplevel;
***************
*** 345,351 ****
XtOverrideTranslations(selFileField,
XtParseTranslationTable(oneLineTextEditTranslations));
! XtSetKeyboardFocus(selFileForm, selFileField);
i = 0;
XtSetArg(arglist[i], XtNorientation, XtorientHorizontal); i++;
--- 451,458 ----
XtOverrideTranslations(selFileField,
XtParseTranslationTable(oneLineTextEditTranslations));
! /* XtSetKeyboardFocus(selFileForm, selFileField);
! need focus for selFileMask wigget to set the filter */
i = 0;
XtSetArg(arglist[i], XtNorientation, XtorientHorizontal); i++;
***************
*** 473,478 ****
--- 580,650 ----
selFileCancel = XtCreateManagedWidget("selFileCancel",
commandWidgetClass, selFileForm, arglist, i);
+ /* addition for file filter */
+ selFileLabel = XtVaCreateManagedWidget("selFileLabel",
+ labelWidgetClass, selFileForm,
+ XtNfromVert, selFileLists[0],
+ XtNvertDistance, 30,
+ XtNfromHoriz, selFileCancel,
+ XtNhorizDistance, 60,
+ XtNlabel, "File Mask:",
+ XtNborderWidth, 0,
+ XtNtop, XtChainTop,
+ XtNbottom, XtChainTop,
+ NULL);
+
+ selFileMask = XtVaCreateManagedWidget("selFileMask",
+ asciiTextWidgetClass, selFileForm,
+ XtNwidth, MASKWIDTH*SFcharWidth,
+ XtNfromVert, selFileLists[0],
+ XtNvertDistance, 30,
+ XtNfromHoriz, selFileLabel,
+ XtNhorizDistance, 0,
+ XtNtop, XtChainTop,
+ XtNbottom, XtChainTop,
+ XtNstring, fileMask,
+ XtNlength, sizeof(fileMask),
+ XtNeditType, XawtextEdit,
+ XtNwrap, XawtextWrapNever,
+ XtNuseStringInPlace, True,
+ NULL);
+
+ for (i = 0; i < 3; i++)
+ XtSetKeyboardFocus(selFileLists[i], selFileField);
+
+ XtOverrideTranslations(selFileMask,
+ XtParseTranslationTable(oneLineTextEditTranslations));
+
+ XtAddEventHandler(selFileMask, KeyPressMask, False,
+ maskChanged, (XtPointer) NULL);
+
+ selFileLabel = XtVaCreateManagedWidget("selFileLabel",
+ labelWidgetClass, selFileForm,
+ XtNfromVert, selFileLists[0],
+ XtNvertDistance, 30,
+ XtNfromHoriz, selFileMask,
+ XtNhorizDistance, 40,
+ XtNlabel, "dot files",
+ XtNborderWidth, 0,
+ XtNtop, XtChainTop,
+ XtNbottom, XtChainTop,
+ NULL);
+
+ selFileHide = XtVaCreateManagedWidget("selFileHide",
+ commandWidgetClass, selFileForm,
+ XtNfromVert, selFileLists[0],
+ XtNvertDistance, 30,
+ XtNfromHoriz, selFileLabel,
+ XtNhorizDistance, 2,
+ XtNlabel, "hidden",
+ XtNborderWidth, 0,
+ XtNtop, XtChainTop,
+ XtNbottom, XtChainTop,
+ XtNcursorName, "dot",
+ NULL);
+ XtAddCallback(selFileHide, XtNcallback, hideFiles, NULL);
+ /* end addition */
+
XtSetMappedWhenManaged(selFile, False);
XtRealizeWidget(selFile);
***************
*** 577,588 ****
strlen(prompt) + 2);
strcpy(buf, failed);
strcat(buf, sys_errlist[errno]);
! strcat(buf, "\n");
strcat(buf, prompt);
} else {
buf = XtMalloc(strlen(failed) + strlen(prompt) + 2);
strcpy(buf, failed);
! strcat(buf, "\n");
strcat(buf, prompt);
}
XtSetArg(args[0], XtNlabel, buf);
--- 749,762 ----
strlen(prompt) + 2);
strcpy(buf, failed);
strcat(buf, sys_errlist[errno]);
! /* strcat(buf, "\n"); */
! strcat(buf, " ");
strcat(buf, prompt);
} else {
buf = XtMalloc(strlen(failed) + strlen(prompt) + 2);
strcpy(buf, failed);
! /* strcat(buf, "\n"); */
! strcat(buf, " ");
strcat(buf, prompt);
}
XtSetArg(args[0], XtNlabel, buf);
***************
*** 726,732 ****
(void) strcpy(SFcurrentPath, SFstartDir);
}
! SFfunc = show_entry;
SFtextChanged();
--- 900,908 ----
(void) strcpy(SFcurrentPath, SFstartDir);
}
! /* SFfunc = show_entry;
! disabled in order to implement file filter */
! SFfunc = showEntry;
SFtextChanged();
-------------- end of patch ----------
-----------------------------------------------------------------------
PHAM Dinh Tuan | e-mail: Dinh-Tuan.Pham@imag.fr
Laboratoire de Modelisation et Calcul | Tel: +33 76 51 44 23
BP 53, 38041 Grenoble cedex 9 (France) | Fax: +33 76 63 12 63
-----------------------------------------------------------------------